//
//  PHStatusViewModel.swift
//  PHWeibo
//
//  Created by 潘荟 on 16/7/23.
//  Copyright © 2016年 BAT. All rights reserved.
//

import UIKit

class PHStatusViewModel: NSObject {
    
    var status:PHStatus?
    var memberImage:UIImage?
    var avatarImage:UIImage?
    
    
    init(status:PHStatus) {
        
        super.init()
        self.status = status
        
        self.avatarImage = getAvatarImage(status.user?.verified)
        self.memberImage = getMemberImage(status.user?.mbrank)
    }

}

// MARK: - 认证图片和微博等级
extension PHStatusViewModel {
    
    // 处理微博认证用户图片/// 认证类型 -1：没有认证，1，认证用户，2,3,5: 企业认证，220: 达人
    func getAvatarImage(verified:Int?) -> UIImage?{
        //判断是否为空
        guard let ver = verified else {
            return nil
        }
        
        switch ver {
        case 1:
            return UIImage(named: "avatar_vip")
        case 2,3,5:
            return UIImage(named: "avatar_grassroot")
        case 220:
            return UIImage(named: "avatar_enterprise_vip")
            
        default:
            return UIImage(named: "avatar_vgirl")
        }
    }
    // 处理会员等级图片/// 会员等级 1-6
    func getMemberImage(mbrank:Int?) ->UIImage?{
        
        guard let mb = mbrank else {
            return nil
        }
        
        if mb > 0 && mb < 7 {
            return UIImage(named: "common_icon_membership_level\(mb)")
        }else {
            return UIImage(named: "common_icon_membership_expired")
        }
    }
}










